
import { isObject } from "lodash";
export default {
  props: {
    formData: {
      type: Object,
      require: true,
    },
    prop: {
      type: String,
      require: true,
    },
    label: {
      type: String,
      default: "",
    },
    dicData: {
      type: Object | Array,
    },
    filed: {
      type: String,
      default: "label",
    },
    returnFiled: {
      type: String,
      default: "value",
    },
    require: {
      type: Boolean,
      default: false,
    },
    placeholder: {
      type: String,
      default: "",
    },
    width: {
      type: String | Number,
      default: "8",
    },
    height: {
      type: String | Number,
      default: "1.25",
    },
    background: {
      type: String,
    },
    borderColor: {
      type: String,
    },
    color: {
      type: String,
    },
    border: {
      type: String,
    },
    hwd: {
      type: String,
    },
    clearable:{
      type: Boolean,
      default: true
    },
    type:{
      type: String
    }
  },
  data() {
    return {
      value: undefined,
    };
  },
  computed: {
    placeholderSync() {
      if (this.placeholder === '') return ''
      return this.placeholder || `${$AONE_LAN.plsInput}${this.label}`;
    },
    dicDataSync() {
      return this.dicData?.map?.((it) => {
        if (!isObject(it)) {
          return {
            label: it,
            value: it,
          };
        }
        return {
          label: it[this.filed],
          value: it[this.returnFiled],
        };
      }) || [];
    },
  },
  methods: {
    renderLabel() {
      return this.label ? (
        <p class="label">
          {this.require ? <span class="red">*</span> : null}
          {this.label}：
        </p>
      ) : null;
    },
  }
}
